﻿@model TestUp.Models.UserModels.PendingTestsModel

@{
    ViewBag.Title = "Tests";
    Layout = "~/Views/User/_UserNavigationLayout.cshtml";
}

<script type="text/javascript">
    function openTest(e) {
        e.preventDefault();
        var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
        var id = dataItem.PendingTestId;

        window.location = "/User/OpenPendingTest/" + id;
    }
</script>

<h2>Tests Available</h2>

@(Html.Kendo().Grid(Model.PendingTests)
.Name("userPendingTestsGrid")
.Columns(cols =>
    {
        cols.Bound(x => x.TestId).Hidden(true);
        cols.Bound(x => x.Test.TestName);
        cols.Bound(x => x.ExpirationDate);
        cols.Command(cmd => cmd.Custom("Open").Click("openTest"));
    })
.DataSource(dataSource => dataSource
        .Ajax()
        .Model(model => model.Id(x=>x.TestId))
        )
)